<template>
  <basic-container>
    <avue-crud
        v-bind="bindVal"
        v-on="onEvent"
        :page.sync="page"
        v-model="startForm">
      <template slot-scope="{type,size,row}" slot="menuBtn">
        <el-dropdown-item v-if="getBtnPermission('platformMigrationBtn',row,null,false)"
                          icon="el-icon-edit" :size="size" @click.native="platformUser(row)" :type="type">
          平台用户迁移
        </el-dropdown-item>
        <el-dropdown-item v-if="getBtnPermission('changeEnableBtn',row,null,false)&&1===row.isEnable"
                          icon="el-icon-edit" :size="size" @click.native="changeEnableState(row,0)" :type="type">
          禁用
        </el-dropdown-item>
        <el-dropdown-item v-if="getBtnPermission('changeEnableBtn',row,null,false)&&0===row.isEnable"
                          icon="el-icon-edit" :size="size" @click.native="changeEnableState(row,1)" :type="type">
          启用
        </el-dropdown-item>
      </template>
    </avue-crud>
    <platform-user-migration ref="platformUserMigration"></platform-user-migration>
  </basic-container>
</template>

<script>
import startCrud from "@/mixins/start-crud"
import platformUserMigration from "./platformUserMigration";
import {changeEnableState} from "@/api/tpp/thirdPartyPlatformConfigApi";
export default startCrud({
      components: {platformUserMigration},
      data() {
        return {};
      },
      created() {

      },
      methods: {
        changeEnableState(row,state){
          let data={};
          data.id=row.id
          data.state=state;
          let msg=`是否【${state===0?'禁用':'启用'}】名称为${row.name}的第三方平台？`;
          this.$confirm(msg, '系统提示', {
            confirmButtonText: '是',
            cancelButtonText: '否',
            type: 'warning'
          }).then(()=>{
            return changeEnableState(data)
          }).then(res=>{
            this.refreshChange();
          })

        },
        platformUser(row) {
          this.$refs.platformUserMigration.show(row);
        }
      }
    },
    {
      name: "tpp/thirdPartyPlatformConfig"
    }
)
</script>

<style scoped>

</style>
